/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.widget;

//import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageView;
//import androidx.core.app.NotificationCompat;
//import com.jcds.learneasy.R;
//import com.jcds.learneasy.entity.Box;
//import com.umeng.analytics.pro.d;
import com.xuexiang.templateproject.bean.Box;
import com.xuexiang.templateproject.R;
import java.util.ArrayList;
//import java.util.Iterator;
//import java.util.Iterator;
import java.util.List;
//import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class BoxImageView extends androidx.appcompat.widget.AppCompatImageView {

    /* renamed from: a  reason: collision with root package name */
    public List<Box> mBoxlist;

    /* renamed from: b  reason: collision with root package name */
    public ArrayList<RectF> mRectFlist;

    /* renamed from: c  reason: collision with root package name */
    public Paint mPaint;
    public BoxImageView(Context context) {
        super((Context)null);

    }

    public BoxImageView(Context context, AttributeSet attrs) {
        super((Context)null);

    }

    public BoxImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super((Context)null);

    }

    @NotNull
    public final List<Box> getBoxList() {
        return this.mBoxlist;
    }

    @Override // android.widget.ImageView, android.view.View
    public void onDraw(@Nullable Canvas canvas) {
        super.onDraw(canvas);
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeWidth(1.0f);
        int color = getResources().getColor(R.color.btn_blue_text);
        mPaint.setColor(color);

        int size = this.mRectFlist.size();
        for (int i2 = 0; i2 < size; i2++) {
            if (canvas != null) {
                Intrinsics.checkNotNull(mPaint);
                canvas.drawRect(this.mRectFlist.get(i2), mPaint);
            }
        }
    }

    @Override // android.view.View
    public void onSizeChanged(int i2, int i3, int i4, int i5) {
        super.onSizeChanged(i2, i3, i4, i5);
        if (i2 > 0 && i3 > 0) {
            int size = this.mBoxlist.size();
            for (int i6 = 0; i6 < size; i6++) {
                RectF rectF = new RectF();
                float f2 = i2;
                float f3 = i3;
                rectF.set(this.mBoxlist.get(i6).getLeftTop().getX() * f2, this.mBoxlist.get(i6).getLeftTop().getY() * f3, f2 * this.mBoxlist.get(i6).getRightTop().getX(), f3 * this.mBoxlist.get(i6).getRightBottom().getY());
                this.mRectFlist.add(rectF);
            }
        }
    }

    @Override // android.view.View
    public boolean onTouchEvent(@Nullable MotionEvent motionEvent) {
        RectF rectF2;
        switch (motionEvent.getAction()){
            case MotionEvent.ACTION_UP:{
                float x = motionEvent.getX();
                float y = motionEvent.getY();
                for(int i=0;i<mRectFlist.size();i++){
                    RectF rectF = mRectFlist.get(i);
                    if (rectF.left >= x || rectF.right <= x || rectF.top >= y || rectF.bottom <= y) {
                        rectF2 = rectF;
                        break;
                    }else{

                    }

                }
                invalidate();
                break;
            }
        }

        return true;
    }

    public final void setBoxList(@NotNull List<Box> list) {
        Intrinsics.checkNotNullParameter(list, "<set-?>");
        this.mBoxlist = list;
    }
}